﻿using System;
using System.Web.UI;
using System.Text;

using Model.AuthModel;
using Util.Helper;
using Com.Ompchina.Lib.Net;
namespace UI.WebPage.Front
{
    public class FrontPageBase : Page
    {
        public StaffInfo LoginStaff = new StaffInfo();
        public int PageIndex = 1;
        public StringBuilder Repo = new StringBuilder();

        #region 页面重载方法
        /// <summary>
        /// 重载预初始化事件
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreInit(EventArgs e)
        {
            //检查栏目是否开启
            this.CheckChannelOnline();
            StaffHelper helper = new StaffHelper();
            LoginStaff = helper.GetLoginStaff();
            base.OnPreInit(e);
        }
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            PageIndex = RequestParam.GetInt(Request, "page", 1);
            base.OnLoad(e);
        }
        #endregion
        

        #region 页面私有方法
        /// <summary>
        /// 检查对应栏目是否开启
        /// </summary>
        /// <returns></returns>
        private void CheckChannelOnline()
        {
            string[] url = this.Page.Request.Url.Segments;
            string channelName = url.Length == 2 ? url[0] : url[1];
            //if (!channelName.Equals("other/") && !new Regular().MatchString(channelName, @"u[\d]+"))
            //{
            //    ChannelOnlineInfo info = new ChannelOnlineBLL().GetChannelOnlineByName(channelName);
            //    if (string.IsNullOrEmpty(info.IsOnline) || info.IsOnline.Equals("n"))
            //    {
            //        if (string.IsNullOrEmpty(info.ChannelDescription))
            //            Response.Redirect(BLL.Main.Util.WebConfig.WebRoot + "other/error.aspx" + "?message=" + Server.UrlEncode("您访问的栏目不存在"));
            //        else
            //            Response.Redirect(BLL.Main.Util.WebConfig.WebRoot + "other/error.aspx" + "?message=" + Server.UrlEncode(info.ChannelDescription));
            //    }
            //}
        }
        #endregion
    }
}
